package com.windrift.ws.order;

import javax.jws.WebService;

/**
 * Created by IntelliJ IDEA.
 * User: cy
 * Date: 9/05/12
 * Time: 3:20 PM
 * To change this template use File | Settings | File Templates.
 */
@WebService(endpointInterface = "com.windrift.ws.order.OrderProcess")
public class OrderProcessImpl implements OrderProcess{

    @Override
    public String processOrder(Order order) {
        String orderId = validate(order);
        return orderId;
    }

    @Override
    public Order anotherMether(String s1, Integer i2) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }


    /**
     * Validates the order and returns the order ID
     **/
    private String validate(Order order) {
        String custID = order.getCustomerId();
        String itemID = order.getItemId();
        int qty = order.getQty();
        double price = order.getPrice();
        if (custID != null && itemID != null && !custID.equals("")
                && !itemID.equals("") && qty > 0
                && price > 0.0) {
            return "ORD1234";
        }
        return null;
    }
}
